package zadanie;

import zadanie.Person;

public class Marek2 {
	public static void main(String[] args) {
		Person[] persons = { new Person(), new Person(), new Person(),
				new Person() };
		Integer b = 0;
		Integer c = 1;
		Integer d = 2;
		// greet person 
		for (Integer a = 0; a < (args.length / 3); a++, b = b + 3, c = c + 3, d = d + 3) {
			persons[a].name = args[b];
			persons[a].surname = args[c];
			persons[a].age = Integer.parseInt(args[d]);
			System.out.println(persons[a].introduceYou());
		}
		System.out.println();
		System.out.println("Wynik z nazwiskiem odwroconym");
		System.out.println("-----------------------------");
		Person reverse = odwrot(persons);
	}

	static Person odwrot(Person[] persons) {
		Person reverse = new Person();
		for (Integer f = 0; f < persons.length; f++) {
			persons[f].surname = new StringBuffer(persons[f].surname).reverse()
					.toString();
			System.out.println(persons[f].introduceYou());
		}
		return reverse;
	}
}
